import { isRef } from "vue";

export const isComputed = (v: any) => !!(v.effect && isRef(v));

export const isObject = (v: any) => typeof v === "object" && v !== null;

export const isFunction = (v: any) => typeof v === "function";

// 发布者
export const publisher = (list: Function[], callback: Function) => {
    list.push(callback);
}

// 订阅者
export const subscriber = (list: Function[], ...args: any[]) => {
    list.slice().forEach((callback) => callback(...args))
}